package com.hspedu.newData.dmsxl.动态规划.基础;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-04 
 * @Version: 1.0
 */

public class LC118杨辉三角 {



    // 动态规划
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> res = new ArrayList<>();
        int[][] dp = new int[numRows][numRows];
        for (int i = 0; i < numRows; i++) {
            List<Integer> path = new ArrayList<>();
            for (int j = 0; j <= i; j++) {
                if (j==0){
                    dp[i][j] = 1;
                }else {
                    dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
                }
                path.add(dp[i][j]);
            }
            res.add(path);
        }
        return res;
    }


    @Test
    public void test() {
        // 测试代码
        generate(5);

    }
}
